//
//  MutViewController.m
//  Select
//
//  Created by dihuijun on 17/3/17.
//  Copyright © 2017年 Cycle. All rights reserved.
//

#import "MutViewController.h"
#import "MutView.h"
@interface MutViewController ()
/**   datasource   */
@property (nonatomic, strong) NSMutableArray *datasource;
/**   mutView   */
@property (nonatomic, strong) MutView *muView;
@end

@implementation MutViewController
/**   datasource   */
- (NSMutableArray *)datasource{
    if(!_datasource){
        _datasource = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    }
    return _datasource;
}
/**   mutView   */
- (MutView *)muView{
    if(!_muView){
        _muView = [MutView sharedMutViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.frame.size.height) title:@"全部"];
        ///把服务器数据传过去
        _muView.datasource = self.datasource;
        
        
        //得到选择的值
        _muView.block = ^(NSString *content,NSMutableArray *chooseArray){
            NSLog(@"\n content: %@   \n chooseArray: %@",content,chooseArray);
        };
    }
    return _muView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"多选";
    [self.view addSubview:self.muView];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Add" style:UIBarButtonItemStyleDone target:self action:@selector(ClickAdd)];
}
- (void)ClickAdd{
    NSUInteger count = self.datasource.count;
    for (int i =0;i<=4; i++) {
        [self.datasource addObject:[NSString stringWithFormat:@"%lu",count+i]];
    }
    self.muView.datasource = self.datasource;
    
    [self.muView reloadData];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
